# -*- coding:utf-8 -*-
#from Crypto.Cipher import AES
import base64
import json

TOKEN_SALT = '2SIXQqcJXIV9SJjb'


def add_to_16(s):
    while len(s) % 16 != 0:
        s += '\0'
    return str.encode(s)  # 返回bytes


def token_encode(key, data):
    pass
    # aes = AES.new(str.encode(key), AES.MODE_ECB)  # 初始化加密器，本例采用ECB加密模式
    # encrypted_text = str(base64.urlsafe_b64encode(aes.encrypt(add_to_16(data))), encoding='utf8').replace('\n',
    #                                                                                                       '')  # 加密
    # return encrypted_text


def token_decode(encrypted_text):
    pass
    # encrypted_text = encrypted_text.replace(" ", "+")
    # key = TOKEN_SALT
    # aes = AES.new(str.encode(key), AES.MODE_ECB)  # 初始化加密器，本例采用ECB加密模式
    # decrypted_text = str(
    #     aes.decrypt(base64.urlsafe_b64decode(bytes(encrypted_text, encoding='utf8'))).rstrip(b'\0').decode("utf8"))
    # return decrypted_text


def __token_generate_for_test():
    pass
    # token_data = {
    #     'timestamp': '2020-03-03 23:19:12',
    #     'account': 'test_hnxt_jcv2',
    #     'user_code': '00874eef8c4947879485c6777826caf0',
    #     'project_code': '12',
    #     'role_code': ''
    # }
    #
    # token = token_encode(TOKEN_SALT, json.dumps(token_data))
    # print("加密")
    # print(token)
    # print("解密")
    # print(token_decode(token))


if __name__ == '__main__':
    # __token_generate_for_test()

    print(token_decode('hSjSlDzUEx6FtcGZdOXtaS5Yx6F6gUJ_1uo5VJwyUJrnTGWrGuJrLSO_6-kwkyB7iX0-p4vmsRHvvpMWhEmCxkCg9W3stMrwRHy5I6QgyqxBDDptzBi4gW5zTmC9fZRrJmoKALcaQt5FvklGlSTkYdc7KWd1Yn-LEWTdVTpYFyQ2yFR_QZymDFGLaU53-VXbxYvKDZEnCoEzoIFxvQpe3jao4-ApmHjvT9k5Y6PFhVY'))
